package com.leyou.sms;

import com.leyou.common.constants.MQConstants;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.HashMap;
import java.util.Map;

/**
 * @package com.leyou.sms
 * @description: 测试发送短信业务
 * @author: 许超越
 * @date 2019/7/6 16:03
 * @version: V1.0
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class test {

    @Autowired
    private AmqpTemplate amqpTemplate;

    @Test
    public void smsTest() {
        Map<String, String> msg = new HashMap<>();
        String code = RandomStringUtils.randomNumeric(6);
        msg.put("phone", "18136634980");
        msg.put("code", code);
        System.out.println(code);
        amqpTemplate.convertAndSend(MQConstants.Exchange.SMS_EXCHANGE_NAME, MQConstants.RoutingKey.VERIFY_CODE_KEY, msg);
    }
}
